<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>商品供应信息</title>
    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
<#include "../template/include/assign.ftl">
<#include "../template/include/source.ftl">
<#include "../template/template_listPage.ftl">
    <link href="${web_static}/admin/css/list.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        .page {
            float: right;
            padding-top: 15px;
            margin-right: 15px;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {

            var $validateErrorContainer = $("#validateErrorContainer");
            var $validateErrorLabelContainer = $("#validateErrorContainer ul");
            var $validateForm = $("#inputForm");
            var $tab = $("#tab");
            // Tab效果
            $tab.tabs(".tabContent", {
                tabs:"input"
            });

            // 表单验证
            $validateForm.validate({
                errorContainer:$validateErrorContainer,
                errorLabelContainer:$validateErrorLabelContainer,
                wrapper:"li",
                errorClass:"validateError",
                ignoreTitle:true,
                rules:{
                    "supplierName":{
                        required:true
                    }
                },
                messages:{
                    "supplierName":{
                        required:"请选供应商名称！！"
                    }
                },
                submitHandler:function (form) {
                    //$(form).find(":submit").attr("disabled", true);
                    form.submit();
                }
            });


            $('#searchButton').click(
                    function () {
                        $('#currentPage_listForm').val('1');
                    }
            );

            if ($.browser.msie && $.browser.version == "6.0") {
                setTimeout(function () {
                    $('#goodsState').val('<#if goodsSupplyQuery??>${(goodsSupplyQuery.goodsState)!}</#if>');
                    $('#rechargeMode').val('<#if goodsSupplyQuery??>${(goodsSupplyQuery.rechargeMode)!}</#if>');
                    $('#enable').val('<#if goodsSupplyQuery??>${(goodsSupplyQuery.enable)!}</#if>');
                }, 1);
            } else {
                $('#goodsState').val('<#if goodsSupplyQuery??>${(goodsSupplyQuery.goodsState)!}</#if>');
                $('#rechargeMode').val('<#if goodsSupplyQuery??>${(goodsSupplyQuery.rechargeMode)!}</#if>');
                $('#enable').val('<#if goodsSupplyQuery??>${(goodsSupplyQuery.enable)!}</#if>');
            }
        <#if actionErrors??&&(actionErrors?size > 0)>
            $.dialog({type:"warn", content:"<#list errorMessages as list>${list}<br></#list>",
                modal:true, autoCloseTime:3000});
        </#if>
        });
        function offline(id, goodsId) {
            var result = confirm("你确认要下架此商品吗?");
            if (result) {
                var url = "${web_base}/game/goods_supply!updateState.htm?goodsState=0&id=" + id + "&goodsId=" + goodsId;
                document.forms[1].action = url;
                document.forms[1].submit();
            }
        }

        function online(id, goodsId) {
            var result = confirm("你确认要上架此商品吗?");
            if (result) {
                var url = "${web_base}/game/goods_supply!updateState.htm?goodsState=1&id=" + id + "&goodsId=" + goodsId;
                document.forms[1].action = url;
                document.forms[1].submit();
            }
        }

        function editPrice(id) {
            var goodsId = $('#goodsId').val();
            var goodsCategoryId = $('#goodsCategoryId').val();
            var goodsName = $('#goodsName').val();
            var supplyName = $('#supplyName').val();
            var oriGoodsId = $('#originalGoodsId').val();
            var url = "${web_base}/game/goods_supply!toEdit.htm?id=" + id;
            if (goodsId != null && goodsId != '') {
                url = url + "&goodsId=" + goodsId;
            }
            if (goodsCategoryId != null && goodsCategoryId != '') {
                url = url + "&goodsCategoryId=" + goodsCategoryId;
            }
            if (goodsName != null && goodsName != '') {
                url = url + "&goodsName=" + goodsName;
            }
            if (supplyName != null && supplyName != '') {
                url = url + "&supplyName=" + supplyName;
            }
            if (oriGoodsId != null && oriGoodsId != '') {
                url = url + "&oriGoodsId=" + oriGoodsId;
            }
            document.forms[1].action = encodeURI(url);
            document.forms[1].submit();
        }
        
         function noticeUser(goodsId){
      	 var url = "${web_base}/game/goods_supply!noticeUser.htm?goodsId=" + goodsId;
      	 document.forms[0].action = encodeURI(url);
         document.forms[0].submit();
       }
        
    </script>
</head>
<body class="list">

<div class="body">
    <div class="listBar">
        <h1><span class="icon">&nbsp;</span>商品供应管理&nbsp;<span class="pageInfo"></span></h1>
    </div>
    <div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
        <ul></ul>
    </div>
    <form id="inputForm" class="validate" action="${web_base}/game/goods_supply!export.htm" method="post">
        <div class="operateBar">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;供应商名称：
            <select name="supplierName" class="formText {required: true}">
                <option value="" selected="selected">
                    -请选供应商名称-
                </option>
            <#if supplyNames??>
                <#list supplyNames as obj>
                    <option value="${obj!}">${obj!}</option>
                </#list>
            </#if>
            </select>
            <input type="submit" id="exportButton" value="导出供应商价格信息"/>
        </div>
    </form>
<@pageList page=(page!) id="listForm" action="${web_base}/game/goods_supply!supplyList.htm" query="goodsSupplyQuery" isEmpty=true>
    <div class="operateBar">
    <#--<input type="button" class="addButton" onclick="location.href='${web_base}/game/goods_supply!add.htm'" value="新增供应商品" />-->
        查&nbsp;找:
        商品编号：<input type="text" name="goodsSupplyQuery.goodsId" id="goodsId"
                    value="<#if goodsSupplyQuery??>${(goodsSupplyQuery.goodsId)!}</#if>"/>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        品牌编号：<input type="text" name="goodsSupplyQuery.goodsCategoryId"id="goodsCategoryId"
                   value="<#if goodsSupplyQuery??>${(goodsSupplyQuery.goodsCategoryId)!}</#if>"/>
        商品名称：<input type="text" name="goodsSupplyQuery.goodsName" id="goodsName"
                    value="<#if goodsSupplyQuery??>${(goodsSupplyQuery.goodsName)!}</#if>"/><br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        供应商名称：<input type="text" name="goodsSupplyQuery.supplyName" id="supplyName"
                      value="<#if goodsSupplyQuery??>${(goodsSupplyQuery.supplyName)!}</#if>"/>
        供应商商品编号：<input type="text" name="goodsSupplyQuery.originalGoodsId" id="originalGoodsId"
                       value="<#if goodsSupplyQuery??>${(goodsSupplyQuery.originalGoodsId)!}</#if>"/>
        商品状态：<select name="goodsSupplyQuery.goodsState" id="goodsState">
        <option value="1">
            上架
        </option>
        <option value="0">
            下架
        </option>
    </select>
        充值方式：<select name="goodsSupplyQuery.rechargeMode" id="rechargeMode">
        <option value="" selected="selected">请选择...</option>
        <option value="2">
            直充
        </option>
        <option value="1">
            卡充
        </option>
    </select>
        <input type="submit" id="searchButton" class="searchButton" value=""/>
    </div>
    <table class="listTable">
        <tr>
        <#--<th>
                          <span>序号</span>
                      </th>-->
            <th>
                <span name="goodsId">商品编号</span>
            </th>
            <th>
                <span name="goodsCategoryId">品牌编号</span>
            </th>
            <th>
                <span name="goodsName">商品名称</span>
            </th>
            <th>
                <span name="supplyName">供应商名称</span>
            </th>
            <th>
                <span name="originalGoodsId">供应商商品编号</span>
            </th>
            <th>
                <span name="goodsCostPrice">商品进价(元)</span>
            </th>
            <th>
                <span name="goodsValue">商品面值(元)</span>
            </th>
        <#--<th>-->
        <#--<span  name="goodsState">商品状态</span>-->
        <#--</th>-->
            <th>
                <span name="rechargeMode">充值方式</span>
            </th>
            <th>
                <span class="sort" name="insertTime">录入时间</span>
            </th>
            <th>
                <span class="sort" name="modifyTime">修改时间</span>
            </th>
            <th>
                <span class="sort" name="operator">操作员</span>
            </th>
            <th width="80">操&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;作
            <th/>
        </tr>

        <#if page?? && page.list?? && (page.list?size gt 0)>
            <#list page.list as obj>
                <tr>
                <#--<td>${obj_index+page.pageSize*(page.currentPage-1)+1}</td>-->
                    <td>
                    ${(obj.goodsId)!}
                    </td>
                    <td>
                    ${(obj.goodsCategoryId)!}
                    </td>
                    <td>
                        <#if obj.goodsName?? && obj.goodsName?length gt 10>
                        <#--//截取输出文字的长度-->
                        ${obj.goodsName?substring(0,10)}...
                        <#else>
                        ${(obj.goodsName)!}
                        </#if>
                    </td>
                    <td>
                    ${(obj.supplyName)!}
                    </td>
                    <td>
                    ${(obj.originalGoodsId)!}
                    </td>
                    <td>
                    ${(obj.goodsCostPrice*1.0/1000)?string("0.000")}
                    </td>
                    <td>
                        <#if obj.suppliersId?? && obj.suppliersId=="20121002" && obj.goodsValue == 0 >
                                <#else>
                        ${(obj.goodsValue*1.0/1000)?string("0.000")}
                        </#if>
                    </td>

                <#--<td>-->
                <#--<#if obj.goodsState?? && obj.goodsState=="0">-->
                <#--下架-->
                <#--<#elseif obj.goodsState?? && obj.goodsState=="1">-->
                <#--上架-->
                <#--</#if>-->
                <#--</td>-->
                    <td>
                        <#if obj.rechargeMode?? && obj.rechargeMode=="2">
                            直充
                        <#elseif obj.rechargeMode?? && obj.rechargeMode=="1">
                            卡充
                        </#if>
                    </td>
                    <td>
                    ${(obj.insertTime)!}
                    </td>
                    <td>
                    ${(obj.modifyTime)!}
                    </td>
                    <td>
                    ${(obj.operator)!}
                    </td>
                    <td width="80">
                        <#if obj.goodsState?? && obj.goodsState=="0">
                            <span class="spanLink" onclick="online('${(obj.id)!}','${obj.goodsId}');"
                                  title="上架">[上架]</span>
                        <#else>
                            [上架]
                        </#if>
                        <#if obj.goodsState?? && obj.goodsState=="1">
                            <span class="spanLink" onclick="offline('${(obj.id)!}','${obj.goodsId}');"
                                  title="下架">[下架]</span>
                        <#else>
                            [下架]
                        </#if><br/>
                        <span class="spanLink" onclick="editPrice('${obj.id}');"
                              title="编辑">[编辑]</span>
                        <a href="${web_base}/game/goods_supply!detail.htm?id=${(obj.id)!}"
                           title="详情">[详情]</a>
                        <br>
                        <span class="spanLink" onclick="noticeUser('${obj.goodsId}');"
                              title="通知下游">[通知下游]</span>
                    </td>
                </tr>
            </#list>
        </#if>
    </table>

    <#if page?? && page.list?? && (page.list?size <= 0)>
        <div class="noRecord">
            没有找到任何记录!
        </div>
    </#if>
</@pageList>
</div>

</body>
</html>